<template>
  <div class="root">
    <!-- <h1>hello vue</h1> -->
    <MyHeader
      :bgColor="'#1d7bff'"
      :fontColor="'#333'"
      title="购物车"
    ></MyHeader>
    <MyGoods v-for="item in goodsList" :key="item.id" :obj="item"></MyGoods>
    <MyFooter :arr="goodsList"></MyFooter>
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader.vue";
import MyGoods from "./components/MyGoods.vue";
import MyFooter from "./components/MyFooter.vue";
import { getCart } from "@/api/cart.js";

export default {
  data() {
    return {
      goodsList: [],
    };
  },

  components: {
    MyHeader,
    MyGoods,
    MyFooter,
  },

  //构造函数
  created() {
    getCart().then((res) => {
      console.log("请求成功", res);

      this.goodsList = res.data.list;
    });
  },
};
</script>

<style>
.root {
  padding-top: 45px;
}
</style>